FROM php:8.1.12RC1-zts-alpine3.15

MAINTAINER sweet3c

ENV TIMEZONE=Asia/Shanghai

# 定义Nginx及虚拟机配置文件，可根据实际情况修改路径
ARG NGINX_CONF_DIR=conf/nginx
ARG FPM_CONF=conf/php-fpm/php-fpm.conf
ARG FPM_WWW_CONF=conf/php-fpm/www.conf
ARG PHP_CONF=conf/php/php.ini
ARG REDIS_VERSION=5.3.7

ADD ../scripts/start.sh /start.sh
# Add-Composer
ADD ../source/composer /usr/bin/composer
ADD source/redis-${REDIS_VERSION}.tgz /tmp/

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
    && apk add --no-cache --repository http://mirrors.aliyun.com/alpine/v3.15/community \
    && apk add zlib-dev libpng-dev libzip-dev \
    && docker-php-source extract \
    && mv -f /tmp/redis-${REDIS_VERSION} /usr/src/php/ext/redis \
    && docker-php-ext-install mysqli pdo_mysql redis bcmath gd zip\
    && chmod a+x /usr/bin/composer /start.sh \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
    && apk add --no-cache nginx tzdata monit bash \
    && cp /usr/share/zoneinfo/$TIMEZONE /etc/localtime \
    && apk del tzdata \
    && mkdir /var/log/php \
    && cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini \
    && rm -rf /etc/nginx/nginx.conf /etc/nginx/conf.d/default.conf /etc/monitrc /usr/local/etc/php-fpm.d/* /usr/local/etc/php-fpm.conf \
    && sed -i "s|.*date.timezone =.*|date.timezone = $TIMEZONE|i" /usr/local/etc/php/php.ini \
    && docker-php-source delete \
    && rm -f /tmp/*

ADD ${NGINX_CONF_DIR}/nginx.conf /etc/nginx/nginx.conf
ADD ${FPM_CONF} /usr/local/etc/php-fpm.conf
ADD ${FPM_WWW_CONF} /usr/local/etc/php-fpm.d/www.conf
COPY ${NGINX_CONF_DIR}/conf.d/* /etc/nginx/conf.d/
#
ADD ../conf/monit.conf /etc/monitrc

VOLUME /var/www

EXPOSE 9000

ENTRYPOINT  ["/bin/bash","/start.sh"]
